﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraBars;
using System.Data.SqlClient;
using CTEM.Controllers.Global;
using CTEM.Models;
using CTEM.Controllers.BUS;
using DevExpress.XtraPrinting;

namespace CTEM.ModuleForms.ManageReport
{
    public partial class WorkerSalaryReport : DevExpress.XtraBars.Ribbon.RibbonForm
    {

        private WorkerSalaryReportChoosed workerSalaryReportChoosed;
        public WorkerSalaryReport()
        {

            workerSalaryReportChoosed = new WorkerSalaryReportChoosed();
            workerSalaryReportChoosed.Show();
            InitializeComponent();
            workerSalaryReportChoosed.AskInformationChanged += new WorkerSalaryReportChoosed.WorkerSalaryDelegate(loadData);
            this.IsMdiContainer = false;
          
        }

        public void loadData(WorkerSalaryDTO workerSalary)
        {
            
            List<WorkerDTO> listWorker = new List<WorkerDTO>();
            List<DayWorkingDTO> listDay = new List<DayWorkingDTO>();
            WorkerSalaryBUS workerSalaryBUS = new WorkerSalaryBUS();
            WorkerBUS workerBUS = new WorkerBUS();
            XtraReport1 report = new XtraReport1();
            listWorker = workerBUS.LoadAllWks(workerSalary.WorkersSalaryID);
            for (int i = 0; i < listWorker.Count; i++)
            {
                listWorker[i].dayWorking = workerBUS.LoadAllDaysWorking(listWorker[i].WorkerID);
            }
            workerSalary.listWork = listWorker;
            report.BindData(workerSalary);

            printControl1.PrintingSystem = report.PrintingSystem;
            report.CreateDocument();
        }

        private void WorkerSalaryReport_Load(object sender, EventArgs e)
        {
           
        }

        private void btExportReport_ItemClick(object sender, ItemClickEventArgs e)
        {
            workerSalaryReportChoosed.Visible = true;
        }

        private void WorkerSalaryReport_FormClosing(object sender, FormClosingEventArgs e)
        {
            workerSalaryReportChoosed.Close();
        }


        
    }
    
}